home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Hot Mix 17
/
Hot Mix 17.iso
/
HM17_SGI
/
research
/
lib
/
write_spr.pro
< prev
next >
Wrap
Text File
|
1997-07-08
|
2KB
|
79 lines
;$Id: write_spr.pro,v 1.7 1997/01/15 03:11:50 ali Exp $
;
; Copyright (c) 1994-1997, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
;+
; NAME:
; WRITE_SPR
;
; PURPOSE:
; This procedure writes a row-indexed sparse matrix stucture to a
; specified file. A row-indexed sparse matrix is created by the
; Numerical Recipes routine SPRSIN.
;
; CATEGORY:
; Sparse Matrix File I/O
;
; CALLING SEQUENCE:
; WRITE_SPR, AS, 'Filename'
;
; INPUTS:
; AS: row indexed sparse matrix created by SPRSIN
; Filename: Name of file to contain AS.
;
; KEYWORDS:
; NONE
;
; OUTPUTS:
; NONE
;
; EXAMPLE:
; a = [[3.,0., 1., 0., 0.],$
; [0.,4., 0., 0., 0.],$
; [0.,7., 5., 9., 0.],$
; [0.,0., 0., 0., 2.],$
; [0.,0., 0., 6., 5.]]
;
; as = SPRSIN(a)
;
; WRITE_SPR, as, 'sprs.as'
;
; MODIFICATION HISTORY:
; Written by: BMH, 1/94.
; Modified: GGS, RSI, July 1996
; Changed NR_SPRSIN to SPRSIN.
;-
PRO WRITE_SPR, as, filename
; as structure format = {sa:FLTARR(nmax) or sa:DBLARR(nmax), - value array
; ija:LONARR(nmax)} - index array
;
ON_IOERROR, BADFILE
info = SIZE(as.(0)) ;Access type and size information for the sa array
nmax = info[1] ;sa and ija vectors are of equal length.
type = info[2] ;Type of matrix value vector (sa)
OPENW, fileLUN, filename, /GET_LUN
;Store type and size info for file read
WRITEU, fileLUN, nmax, type, as
FREE_LUN, fileLUN
RETURN
BADFILE:
IF (N_Elements(fileLUN) GT 0L) THEN $
FREE_LUN, fileLUN
MESSAGE, 'Error writing to sparse matrix file: ' + filename
END